//
//  ITHTMLViewController.m
//  InduceTool
//
//  Created by 魏延龙 on 2020/9/28.
//  Copyright © 2020 魏延龙. All rights reserved.
//

#import "ITHTMLViewController.h"
#import <WebKit/WebKit.h>
#import "ITHTMLTableViewCell.h"
@interface ITHTMLViewController ()<UITableViewDelegate, UITableViewDataSource>

@property (nonatomic, strong) UITableView *tableView;

@end

@implementation ITHTMLViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.

    self.view.backgroundColor = [UIColor whiteColor];
    [self setupViews];
    
}

-(void)viewWillLayoutSubviews {
    self.tableView.frame = self.view.bounds;
}

-(void)setupViews {
    self.tableView = [[UITableView alloc] init];
    self.tableView.delegate = self;
    self.tableView.dataSource = self;
    [self.tableView registerClass:[ITHTMLTableViewCell class] forCellReuseIdentifier:@"cell"];
    [self.view addSubview:self.tableView];
    
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return 20;
}

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    ITHTMLTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell" forIndexPath:indexPath];
    
    
     NSString *content1 = @"<input type='text' value='Submit' /> Come <img src=http://himg.bdimg.com/sys/portraitn/item/62e6c0edb9a4b4f3bda3bfcd0215>alive.</font><font color='#09ce65'><br /><em>Walk </font><font color='#F96d5f'>and</font><font color='#09ce65'> </font><font color='#F96d5f'>talk,</font><font color='#09ce65'></em><br />On </font><font color='#F96d5f'>the</font><font color='#09ce65'> </font><font color='#F96d5f'>count</font><font color='#09ce65'> </font><font color='#F96d5f'>of</font><font color='#09ce65'> </font><font color='#F96d5f'>five.</font><font color='#09ce65'><br /><u>One, </font><font color='#F96d5f'>two,</font><font color='#09ce65'> </font><font color='#F96d5f'>three,</font><font color='#09ce65'> </font><font color='#F96d5f'>four,</font><font color='#09ce65'> </font><font color='#F96d5f'>five.</font><font color='#09ce65'></u><br /><strong><em>Maskman: </font><font color='#F96d5f'>Hello,</font><font color='#09ce65'> </font><font color='#F96d5f'>Marie.</font><font color='#09ce65'></em></strong><br /><div style=\"text-align:right;\">Marie: </font><font color='#F96d5f'>Hello,</font><font color='#09ce65'> </font><font color='#F96d5f'>Maskman.</font><font color='#09ce65'> Close </font><font color='#F96d5f'>the</font><font color='#09ce65'> </font><font color='#F96d5f'>door,</font><font color='#09ce65'> </font><font color='#F96d5f'>please.</font><font color='#09ce65'> Sit </font><font color='#F96d5f'>down</font><font color='#09ce65'> </font><font color='#F96d5f'>here.</font>";
    
    NSAttributedString * htmlAttributedString = [[NSAttributedString alloc] initWithData:[content1 dataUsingEncoding:NSUnicodeStringEncoding] options:@{NSDocumentTypeDocumentAttribute: NSHTMLTextDocumentType} documentAttributes:nil error:nil];
    
//    [cell sethtmlstr:content1];
    [cell setattr:htmlAttributedString];
    
    return cell;
}

-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
    return 180;
}

@end
